/*
package NiuKe;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

*/
/**
 * @Description:
 * @Author: Hanzao
 * @Date: 2022/06/12/21:15
 *//*

public class HJ8 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        Map<Integer,Integer> map = new TreeMap<Integer,Integer>();
        int tmp1 = 0;
        int tmp2 = 0;
        for(int i=0;i<num;i++){
            tmp1 = scanner.nextInt();
            tmp2 = scanner.nextInt();
            if(map.keySet().contains(tmp1)){
                map.put(tmp1,map.get(tmp1)+tmp2);
            }
            else{
                map.put(tmp1,tmp2);
            }
        }
        for (Integer integer : map.keySet()) {
            System.out.println(integer+" "+map.get(integer));
        }
    }
}
*/
